package itdep.common.context.spring;

import org.springframework.security.acls.model.AccessControlEntry;
import org.springframework.security.acls.model.Acl;
import org.springframework.security.acls.model.Permission;
import org.springframework.security.acls.model.Sid;

import java.io.Serializable;

/**
 * @author $Author: ikhalopik $ (latest modification by $Author: ikhalopik $:)
 * @version $Revision: 4 $   $Date: 2010-06-10 13:13:16 +0000 (Thu, 10 Jun 2010) $
 */
public class DynamicAce implements AccessControlEntry {
	private Acl acl;
	private Permission permission;
	private Sid sid;
	private boolean granting;

	public DynamicAce(final Acl acl, final Permission permission, final Sid sid) {
		this.acl = acl;
		this.permission = permission;
		this.sid = sid;
	}

	@Override
	public Acl getAcl() {
		return acl;
	}

	@Override
	public Serializable getId() {
		return null;  //todo: default implementation
	}

	@Override
	public Permission getPermission() {
		return permission;
	}

	@Override
	public Sid getSid() {
		return sid;
	}

	@Override
	public boolean isGranting() {
		return granting;
	}

	public boolean grant() {
		return granting = true;
	}

	public boolean deny() {
		return granting = false;
	}
}
